package edu.pitt.cs.cs2410pj2.util;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Customized logger, printing out messages and writes to a file
 * @author zhangfan
 *
 */
public class TheLogger {
	private String loggerFile = "log.txt";
	private BufferedWriter writer;
	public TheLogger() throws IOException {
		writer = new BufferedWriter(new FileWriter(loggerFile));
	}
	
	public void setLoggerFile(String loggerFile) throws IOException {
		writer = new BufferedWriter(new FileWriter(loggerFile));
	}
	
	public void closeLogger() throws IOException {
		writer.close();
	}
	
	public void log(String msg) throws IOException {
		System.out.println(msg);
		writer.append(msg+"\n");
	}
}
